<template>
	<view>
		<page-head :title="'产品审批'" :headtype="2"></page-head>
		
		<block v-if="assessusermsg.type == 2">
			<!-- 审核员1 -->
			<view class="submittime marginAuto" v-if="datas.audit1_status == 0">提交时间：{{ datas.create_time }}</view>
			<view class="sanctionend marginAuto" v-if="datas.audit1_status != 0">
				<view class="sanctionendstatus" style="color:#40C40C;" v-if="datas.audit1_status == 1">已通过</view>
				<view class="sanctionendstatus" style="color:#E51818;" v-if="datas.audit1_status == 2">已拒绝</view>
				<view class="sanctionendtime">
					<text style="color:#666666;">审批时间:</text>
					<text style="color:#333333;">{{ timegs(datas.audit1_time) }}</text>
				</view>
			</view>
		</block>
		<block v-if="assessusermsg.type == 3">
			<!-- 审核员2 -->
			<view class="submittime marginAuto" v-if="datas.audit2_status == 0">提交时间：{{ datas.create_time }}</view>
			<view class="sanctionend marginAuto" v-if="datas.audit2_status != 0">
				<view class="sanctionendstatus" style="color:#40C40C;" v-if="datas.audit2_status == 1">已通过</view>
				<view class="sanctionendstatus" style="color:#E51818;" v-if="datas.audit2_status == 2">已拒绝</view>
				<view class="sanctionendtime">
					<text style="color:#666666;">审批时间:</text>
					<text style="color:#333333;">{{ timegs(datas.audit2_time) }}</text>
				</view>
			</view>
		</block>
		<view class="reportmsg marginAuto">
			<view class="reporteach flex">
				<view class="reporttitle">报单数量：</view>
				<view class="reportnum flex" v-if="assessusermsg.type == 2 && datas.audit1_status == 0">
					<input class="reportnuminput" type="number" v-model="ordernum"/>
					吨
					<view class="reportnumbtn mainBg baiColor" @click="setnumfun()">确认</view>
				</view>
				<view class="reportnum" v-else>{{ ordernum }}吨</view>
			</view>
			<view class="reporteach flex" v-if="datas.audit1_status > 0 || datas.audit2_status > 0">
				<view class="reporttitle">提交时间：</view>
				<view class="reportnum">{{ datas.create_time }}</view>
			</view>
		</view>
		<view class="sqitem marginAuto">
			<view class="sqitemt flex">
				<view class="sqitemtl flex">
					<view class="sqitemtltitle">{{ datas.detail.goods_name}}</view>
				</view>
				<view class="sqitemtstatus flex" style="color:#E51818;">
					<view style="margin-right:10rpx;">报价倒计时</view>
					<view v-if="countdown <= 0">已截止</view>
					<uv-count-down
					v-if="countdown > 0"
					:time="countdown * 1000" 
					format="DD HH:mm:ss"
					@change="djschange"
					@finish="djsend(datas.detail.goods_end_time)">
					<view class="flex" style="line-height: 36rpx;">
						<view class="djseach" style="margin-right: 10rpx;">{{ timeData.days >= 10?timeData.days:'0'+timeData.days }}天</view>
						<view class="djseach">{{ timeData.hours >= 10 ? timeData.hours:'0'+timeData.hours }}</view>
						: <view class="djseach">{{ timeData.minutes >= 10 ? timeData.minutes : '0'+ timeData.minutes }}</view>
						: <view class="djseach">{{ timeData.seconds >= 10 ? timeData.seconds : '0'+ timeData.seconds }}</view>
					</view>
					</uv-count-down>
				</view>
			</view>
			<view class="sqitemc flex">
				<view class="endtimeimg">
					<image v-if="!datas.detail.goods_image" :src="apifun.serveimg + 'homegoods.png'" mode=""></image>
					<image v-if="datas.detail.goods_image" :src="apifun.URLimg+datas.detail.goods_image" mode=""></image>
				</view>
				<view class="endtimemsg">
					<view class="endtimemsg-title">预售数量(吨): <text style="font-weight:600;">{{ datas.detail.goods_total }}</text></view>
					<view class="endtimemsg-convert">
						<view class="converteach" v-for="(items,indexs) in datas.detail.goods_sku_detail">{{ items.min }}吨-{{ items.max }}吨以内{{ items.price }}元</view>
					</view>
				</view>
			</view>
			<view class="sqitemb">企业名称：{{ datas.company }}</view>
			<view class="sqitemb">用户姓名：{{ datas.username }}</view>
			<view class="sqitemb">用户手机号：{{ datas.mobile }}</view>
			<view class="sqitemb" style="color:#E51818;">截止时间：{{ timegs(datas.detail.goods_end_time) }}</view>
		</view>
		<view class="sanctionr" v-if="datas.audit1_status > 0 || datas.audit2_status > 0">
			<view class="sanctionrtitle marginAuto">审批员</view>
			<view class="sanctionreach flex marginAuto" v-if="datas.audit1_status > 0">
				<view class="sqiteml">
					<image v-if="datas.auditor1_avatar" :src="apifun.URLimg + datas.auditor1_avatar" mode=""></image>
					<image v-if="!datas.auditor1_avatar" src="../../static/logo.png" mode=""></image>
				</view>
				<view class="sqitemc">
					<view class="sqitemctitle ellipsis01">{{ datas.auditor1_name }}</view>
					<view class="sqitemctime">审批时间：{{ timegs(datas.audit1_time) }}</view>
				</view>
				<view class="sqitemr">
					<view class="sqitemrstatus">
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="datas.audit1_status == 1">
							<uv-icon name="checkmark-circle-fill" :color="'#2340FF'" size="20"></uv-icon>
						</view>
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="datas.audit1_status == 2">
							<uv-icon name="close-circle-fill" :color="'#E51818'" size="20"></uv-icon>
						</view>
					</view>
					<view class="sqitemrbtn">
						<!-- <text style="color:#E51818;margin-top:20rpx;" v-if="datas.audit1_status == 0">待审批</text> -->
						<text style="color:#2340FF" v-if="datas.audit1_status == 1">通过</text>
						<text style="color:#E51818;" v-if="datas.audit1_status == 2">拒绝</text>
					</view>
				</view>
			</view>
			<view class="sanctionreach flex marginAuto" v-if="datas.audit2_status > 0">
				<view class="sqiteml">
					<image v-if="datas.auditor2_avatar" :src="apifun.URLimg + datas.auditor2_avatar" mode=""></image>
					<image v-if="!datas.auditor2_avatar" src="../../static/logo.png" mode=""></image>
				</view>
				<view class="sqitemc">
					<view class="sqitemctitle ellipsis01">{{ datas.auditor2_name }}</view>
					<view class="sqitemctime">审批时间：{{ timegs(datas.audit2_time) }}</view>
				</view>
				<view class="sqitemr">
					<view class="sqitemrstatus">
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="datas.audit2_status == 1">
							<uv-icon name="checkmark-circle-fill" :color="'#2340FF'" size="20"></uv-icon>
						</view>
						<view class="sqiteml marginAuto" style="width:60rpx;height:50rpx;" v-if="datas.audit2_status == 2">
							<uv-icon name="close-circle-fill" :color="'#E51818'" size="20"></uv-icon>
						</view>
					</view>
					<view class="sqitemrbtn">
						<!-- <text style="color:#E51818;margin-top:20rpx;" v-if="datas.audit2_status == 0">待审批</text> -->
						<text style="color:#2340FF" v-if="datas.audit2_status == 1">通过</text>
						<text style="color:#E51818;" v-if="datas.audit2_status == 2">拒绝</text>
					</view>
				</view>
			</view>
		</view>
		<view class="funbtn marginAuto flex" v-if="assessusermsg.type == 2 && datas.audit1_status == 0">
			<view class="funbtneach" style="background:#FFD6D6;color:#E51818;" @click="$refs.jjpopup.open()">拒绝</view>
			<view class="funbtneach mainBg baiColor" @click="$refs.typopup.open()">同意</view>
		</view>
		<view class="funbtn marginAuto flex" v-if="assessusermsg.type == 3 && datas.audit2_status == 0">
			<view class="funbtneach" style="background:#FFD6D6;color:#E51818;" @click="$refs.jjpopup.open()">拒绝</view>
			<view class="funbtneach mainBg baiColor" @click="$refs.typopup.open()">同意</view>
		</view>
		<uv-popup ref="typopup" mode="center" round="20">
			<view class="noticepup">
				<view class="noticepuptitle"><text class="noticepuptitlemsg">确定同意审批信息吗？</text></view>
				<view class="boticebtn flex">
					<view class="boticebtneach closebtn" @click="$refs.typopup.close()">取消</view>
					<view class="boticebtneach mainBg baiColor" @click="checkfun(1)">确定</view>
				</view>
			</view>
		</uv-popup>
		<uv-popup ref="jjpopup" mode="center" round="20">
			<view class="noticepup">
				<view class="noticepuptitle"><text class="noticepuptitlemsg">确定拒绝审批信息吗？</text></view>
				<view class="boticebtn flex">
					<view class="boticebtneach closebtn" @click="$refs.jjpopup.close()">取消</view>
					<view class="boticebtneach mainBg baiColor" @click="checkfun(2)">确定</view>
				</view>
			</view>
		</uv-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				assessusermsg:{},
				id:'',
				datas:{
					detail:{
						goods_sku_detail:[]
					}
				},
				timeData:{},
				countdown:'',
				ordernum:'',
			};
		},
		onLoad(option) {
			this.id = option.id;
			this.assessusermsg = uni.getStorageSync('assessusermsg');
			// console.log(this.assessusermsg)
			this.initData();
		},
		methods: {
			initData(){
				let sendData = {
					id:this.id
				};
				this.apifun.unirequest('/auditor/index/getOrderAuditDetail','post',sendData,(res)=>{
					console.log(res)
					if(res.code === 200){
						let datas = res.data;
						this.datas = datas;
						this.ordernum = datas.num;
						this.countdown = datas.detail.goods_end_time - parseInt(new Date().getTime()/1000)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			setnumfun(){
				let sendData = {
					id:this.id,
					num : this.ordernum
				};
				if(this.ordernum <= 0){
					this.apifun.toast('报单数量不得小于0');
					return false
				};
				this.apifun.unirequest('/auditor/index/setOrderNum','post',sendData,(res)=>{
					console.log(res)
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('操作成功')
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			checkfun(type){
				let sendData= {
					ids:this.id,
					status:type
				}
				this.apifun.unirequest('/auditor/index/orderAudit','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('操作成功');
						setTimeout(()=>{
							this.$refs.typopup.close();
							this.$refs.jjpopup.close();
							this.apifun.goback();
						},1500)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			djschange(e){
				let timeData = {};
				timeData = e;
				// if(e.days > 0){
				// 	timeData.hours = e.days*24+e.hours;
				// }
				this.timeData = timeData;
			},
			djsend(item){
				this.$set(item,'countdown',0)
			},
			timegs(time){
				return uni.$uv.timeFormat(time,'yyyy年mm月dd日 hh:MM:ss')
			}
		},
	};
</script>

<style scoped lang="scss">
page{
	background: #FBFBFB;
}
.submittime{
	width: 690rpx;
	font-size: 32rpx;
	color: #333333;
	line-height: 60rpx;
	padding: 10rpx 0;
	font-weight: 600;
}
.sanctionend{
	width: 690rpx;
	padding: 20rpx 0;
	.sanctionendstatus{
		font-size: 34rpx;
		margin-bottom: 20rpx;
	}
	.sanctionendtime{
		font-size:28rpx;
	}
}
.reportmsg{
	background-color: #fff;
	border-radius: 20rpx;
	width: 630rpx;
	padding:0 30rpx;
	margin: 20rpx auto;
	.reporteach{
		justify-content: space-between;
		line-height: 60rpx;
		padding: 20rpx 0;
		.reporttitle{
			font-size: 28rpx;
			color: #666666;
		}
		.reportnum{
			font-size:30rpx;
			color: #333333;
			line-height: 50rpx;
			.reportnumbtn{
				width: 100rpx;
				text-align: center;
				height:50rpx;
				line-height:50rpx;
				font-size: 26rpx;
				border-radius: 5rpx;
				margin-left: 20rpx;
			}
			.reportnuminput{
				border: 1px solid #ccc;
				width:120rpx;
				height:50rpx;
				text-align: center;
				font-size:28rpx;
				border-radius:5rpx;
				margin-right: 10rpx;
			}
		}
	}
}
.sqitem{
	width: 630rpx;
	padding: 0 30rpx;
	background:#fff;
	border-radius:10rpx;
	margin-bottom: 20rpx;
	.sqitemt{
		padding: 20rpx 0;
		border-bottom:1px dashed #F1F1F1;
		justify-content: space-between;
		.sqitemtl{
			.sqitemtltitle{
				font-size: 30rpx;
				color: #333333;
				margin-left:10rpx;
			}
		}
		.sqitemtstatus{
			line-height: 44rpx;
			font-size: 24rpx;
			.djseach{
				padding: 0 10rpx;
				height: 36rpx;
				line-height: 36rpx;
				text-align: center;
				background:#FFEDED;
				color:#E51818;
				margin:0 10rpx;
			}
		}
	}
	.sqitemc{
		padding:20rpx 0;
		.endtimeimg{
			width: 140rpx;
			margin-right: 20rpx;
			image{
				width: 140rpx;
				height: 140rpx;
				border-radius: 10rpx;
			}
		}
		.endtimemsg{
			.endtimemsg-title{
				margin-top:10rpx;
				color:#333333;
				font-size: 30rpx;
			}
			.endtimemsg-convert{
				margin-top: 20rpx;
				.converteach{
					display: inline-block;
					margin-bottom:10rpx;
					margin-right: 10rpx;
					background:#F4F8FC;
					line-height: 52rpx;
					padding:0 10rpx;
					font-size:24rpx;
					color: #2340FF;
					margin-right: 20rpx;
				}
			}
		}
	}
	.sqitemb{
		border-top:1px dashed #F1F1F1;
		font-size:24rpx;
		color: #333;
		line-height:80rpx;
	}
}
.funbtn{
	width: 80%;
	margin-top:100rpx;
	justify-content: space-between;
	.funbtneach{
		width: 240rpx;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		border-radius: 10rpx;
		font-size:30rpx;
	}
}
// popup
.noticepup{
	position: relative;
	width: 600rpx;
	border-radius:30rpx;
	.noticepuptitle{
		position: relative;
		width: 600rpx;
		height: 240rpx;
		font-weight: 600;
		background:linear-gradient(to bottom, #B0D9FF,#ffffff);
		.noticepuptitlemsg{
			position: absolute;
			top:120rpx;
			width: 600rpx;
			height: 70rpx;
			color:#333333;
			font-size: 34rpx;
			text-align: center;
		}
	}
	.boticebtn{
		margin-top:30rpx;
		color: #fff;
		font-size:30rpx;
		width: 600rpx;
		height:100rpx;
		line-height: 100rpx;
		text-align: center;
		.closebtn{
			color:#2340FF;
			background-color: #DBEEFF;
		}
		.boticebtneach{
			width: 50%;
		}
	}
}
// 审批员

.sanctionr{
	.sanctionrtitle{
		width: 690rpx;
		line-height: 50rpx;
		font-size: 32rpx;
		color: #333333;
		padding: 10rpx 0;
	}
	.sanctionreach{
		margin-top:20rpx;
		background:#fff;
		width: 630rpx;
		padding:20rpx 30rpx;
		border-radius: 20rpx;
		justify-content: space-between;
		.sqiteml{
			width: 80rpx;
			height: 80rpx;
			margin-right: 10rpx;
			image{
				width: 80rpx;
				height: 80rpx;
				border-radius: 100rpx;
			}
		}
		.sqitemc{
			width:65%;
			.sqitemctitle{
				font-size: 30rpx;
				color: #333333;
				font-weight: 600;
				line-height: 50rpx;
			}
			.sqitemctime{
				font-size:24rpx;
				color:#666666;
				line-height: 50rpx;
			}
		}
		.sqitemr{
			.sqitemrstatus{
				font-size: 24rpx;
				line-height: 60rpx;
				text-align: center;
			}
			.sqitemrbtn{
				width: 100rpx;
				line-height:60rpx;
				border-radius:10rpx;
				font-size: 30rpx;
				color: #fff;
				text-align: center;
			}
			
		}
	}
}
</style>